Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.ocr = exports.chooseImage = void 0;

var _apiCode = _interopRequireDefault(require("../../utils/api-code")), _util = _interopRequireDefault(require("../../utils/util")), _api = _interopRequireDefault(require("../../utils/api"));

function _interopRequireDefault(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

var chooseImage = function(o) {
    var i = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : 1;
    return new Promise(function(t, e) {
        wx.chooseImage({
            count: i,
            sizeType: [ "compressed" ],
            sourceType: [ o ],
            success: function(e) {
                t(e.tempFilePaths);
            },
            fail: e
        });
    });
};

exports.chooseImage = chooseImage;

var ocr = function(e) {
    return (!(1 < arguments.length && void 0 !== arguments[1]) || arguments[1]) && wx.showLoading({
        title: "智能识别中...",
        mask: !0
    }), new Promise(function(r, t) {
        _api.default.weappcard.ocrbusinesscard({
            param: {
                time: Math.random()
            },
            filePath: e
        }).then(function(e) {
            var t = e.code, o = e.data, i = e.message;
            if (t !== _apiCode.default.SUCCESS) return Promise.reject(i);
            wx.hideLoading(), r(o);
        }).catch(function(e) {
            t(), wx.hideLoading(), _util.default.qAlert(e || "识别图片失败", "识别失败");
        });
    });
};

exports.ocr = ocr;